#include "CMenu.h"

CMenu::CMenu() {
  m_hMenu = NULL;
}

void CMenu::SetHandle(HMENU hMenu) {
  m_hMenu = hMenu;
}

HMENU CMenu::GetHandle() {
  return m_hMenu;
}

HMENU CMenu::GetSubMenu(int nPos) {
  return ::GetSubMenu(m_hMenu, nPos);
}

HMENU CMenu::Create() {
  m_hMenu = CreateMenu();
  return m_hMenu;
}

HMENU CMenu::Create(LPCTSTR lpMenuName) {
  HINSTANCE hInstance = GetModuleHandle(NULL);
  m_hMenu = ::LoadMenu(hInstance, lpMenuName);
  return m_hMenu;
}

HMENU CMenu::Create(UINT nIDTemplate) {
  HINSTANCE hInstance = GetModuleHandle(NULL);
  m_hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(nIDTemplate));
  return m_hMenu;
}

HMENU CMenu::CreatePopup() {
  m_hMenu = CreatePopupMenu();
  return m_hMenu;
}

BOOL CMenu::Destroy() {
  return ::DestroyMenu(m_hMenu);
}

BOOL CMenu::SetInfo(LPMENUINFO lpcmi) {
  return ::SetMenuInfo(m_hMenu, lpcmi);
}

BOOL CMenu::GetInfo(LPMENUINFO lpcmi) {
  return ::GetMenuInfo(m_hMenu, lpcmi);
}

BOOL CMenu::AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, LPCTSTR lpNewItem) {
  return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpNewItem);
}

BOOL CMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem,
    LPCTSTR lpNewItem) {
  return ::InsertMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpNewItem);
}

BOOL CMenu::InsertItem(UINT nItem, BOOL bByPosition, LPCMENUITEMINFO lpmii) {
  return ::InsertMenuItem(m_hMenu, nItem, bByPosition, lpmii);
}

BOOL CMenu::ModifyItem(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem,
    LPCTSTR lpNewItem) {
  return ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpNewItem);
}

UINT CMenu::GetItemCount() {
  return ::GetMenuItemCount(m_hMenu);
}

UINT CMenu::GetItemID(int nPos) {
  return ::GetMenuItemID(m_hMenu, nPos);
}

UINT CMenu::GetState(UINT nIDItem, UINT nFlags) {
  return ::GetMenuState(m_hMenu, nIDItem, nFlags);
}

UINT CMenu::GetString(UINT nIDItem, LPSTR lpString, int nMaxCount, UINT nFlag) {
  return ::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlag);
}

BOOL CMenu::SetItemInfo(UINT nItem, BOOL bByPos, LPMENUITEMINFO lpmii) {
  return ::SetMenuItemInfo(m_hMenu, nItem, bByPos, lpmii);
}

BOOL CMenu::GetItemInfo(UINT nItem, BOOL bByPos, LPMENUITEMINFO lpmii) {
  return ::GetMenuItemInfo(m_hMenu, nItem, bByPos, lpmii);
}

BOOL CMenu::EnableItem(UINT nIDEnableItem, UINT nEnable) {
  return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable);
}

BOOL CMenu::SetItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUnchecked,
    HBITMAP hBmpChecked) {
  return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, hBmpUnchecked,
      hBmpChecked);
}

DWORD CMenu::CheckItem(UINT nIDCheckItem, UINT nCheck) {
  return ::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck);
}

BOOL CMenu::CheckRadioItem(UINT idFirst, UINT idLast, UINT idCheck,
    UINT nFlags) {
  return ::CheckMenuRadioItem(m_hMenu, idFirst, idLast, idCheck, nFlags);
}

BOOL CMenu::SetDefaultItem(UINT nItem, BOOL bByPosition) {
  return ::SetMenuDefaultItem(m_hMenu, nItem, bByPosition);
}

UINT CMenu::GetDefaultItem(BOOL bByPos, UINT nFlags) {
  return ::GetMenuDefaultItem(m_hMenu, bByPos, nFlags);
}

BOOL CMenu::RemoveItem(UINT nPosition, UINT nFlags) {
  return ::RemoveMenu(m_hMenu, nPosition, nFlags);
}

BOOL CMenu::DeleteItem(UINT nPosition, UINT nFlags) {
  return ::DeleteMenu(m_hMenu, nPosition, nFlags);
}

BOOL CMenu::TrackPopup(UINT nFlags, int x, int y, HWND hWnd) {
  return ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0, hWnd, NULL);
}

BOOL CMenu::TrackPopupEx(UINT nFlags, int x, int y, HWND hWnd,
    LPTPMPARAMS lptpm) {
  return ::TrackPopupMenuEx(m_hMenu, nFlags, x, y, hWnd, lptpm);
}

